package com.k.kpp.biz.datasource.model;

/**
 * @author k
 */
public enum DatabaseTypeEnum {
    Sqlite(1, "Sqlite"),
    MySQL(2,"MySQL"),
    PostgreSQL(3, "PostgreSQL"),
    Oracle(4,"Oracle"),
    DEFAULT(1,"Sqlite");

    DatabaseTypeEnum(int i, String s){
        codeInt=i;
        codeStr=s;
    }

    private int codeInt;

    private String codeStr;

    public int getCodeInt() {
        return codeInt;
    }

    public String getCodeStr() {
        return codeStr;
    }

    public static String findStrByInt(int i){
        for (DatabaseTypeEnum item : DatabaseTypeEnum.values()) {
            if (item.getCodeInt() == i) {
                return item.getCodeStr();
            }
        }
        return DEFAULT.getCodeStr();
    }

    public static int findIntByStr(String str){
        for (DatabaseTypeEnum item : DatabaseTypeEnum.values()) {
            if (item.getCodeStr().equals(str.toUpperCase())) {
                return item.getCodeInt();
            }
        }
        return DEFAULT.getCodeInt();
    }
}
